package com.ruoyi.map.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.map.domain.FhMapFishprotection;
import com.ruoyi.map.service.IFhMapFishprotectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 保护鱼种管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/map/fishprotection")
public class FhMapFishprotectionController extends BaseController
{
    @Autowired
    private IFhMapFishprotectionService fhMapFishprotectionService;

    /**
     * 查询保护鱼种管理列表
     */
    @PreAuthorize("@ss.hasPermi('map:fishprotection:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhMapFishprotection fhMapFishprotection)
    {
        startPage();
        List<FhMapFishprotection> list = fhMapFishprotectionService.selectFhMapFishprotectionList(fhMapFishprotection);
        return getDataTable(list);
    }

    /**
     * 导出保护鱼种管理列表
     */
    @PreAuthorize("@ss.hasPermi('map:fishprotection:export')")
    @Log(title = "保护鱼种管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhMapFishprotection fhMapFishprotection) throws IOException {
        List<FhMapFishprotection> list = fhMapFishprotectionService.selectFhMapFishprotectionList(fhMapFishprotection);
        ExcelUtil<FhMapFishprotection> util = new ExcelUtil<FhMapFishprotection>(FhMapFishprotection.class);
        util.exportExcel(response, list, "保护鱼种管理数据");
    }

    /**
     * 获取保护鱼种管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('map:fishprotection:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhMapFishprotectionService.selectFhMapFishprotectionById(id));
    }

    /**
     * 新增保护鱼种管理
     */
    @PreAuthorize("@ss.hasPermi('map:fishprotection:add')")
    @Log(title = "保护鱼种管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhMapFishprotection fhMapFishprotection)
    {
        return toAjax(fhMapFishprotectionService.insertFhMapFishprotection(fhMapFishprotection));
    }

    /**
     * 修改保护鱼种管理
     */
    @PreAuthorize("@ss.hasPermi('map:fishprotection:edit')")
    @Log(title = "保护鱼种管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhMapFishprotection fhMapFishprotection)
    {
        return toAjax(fhMapFishprotectionService.updateFhMapFishprotection(fhMapFishprotection));
    }

    /**
     * 删除保护鱼种管理
     */
    @PreAuthorize("@ss.hasPermi('map:fishprotection:remove')")
    @Log(title = "保护鱼种管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhMapFishprotectionService.deleteFhMapFishprotectionByIds(ids));
    }
}
